//
// Created by Administrator on 2023/8/4.
//
#include <queue>
#include <iostream>
#include <vector>
#include <valarray>

using namespace std;

class Solution {
public:
    long long pickGifts(vector<int> &gifts, int k) {
        priority_queue<int> pq;
        for (int gift: gifts) {
            pq.push(gift);
        }
        for (int i = 0; i < k; ++i) {
            int gift = pq.top();
            pq.pop();
            pq.push(sqrt(gift));
        }
        long long ans = 0;
        while (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
        return ans;
    }
};

int main() {
    Solution s;
    vector<int> gifts{25, 64, 9, 4, 100};
    cout << s.pickGifts(gifts, 4) << endl;
    return 0;
}